﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

/// <summary>
///ConfigBase 的摘要说明
/// </summary>
public class ConfigBase
{
    #region 公开属性
    /// <summary>
    /// 配置文件名称
    /// </summary>
    public string ConfigName { get; set; }
    #endregion

    #region 构造方法
    protected ConfigBase(string ConfigName)
    {
        this.ConfigName = ConfigName;
        path = string.Format("~/Config/{0}.config", this.ConfigName);
        this.InitElement();
    }
    #endregion

    #region  子类中访问属性
    protected XmlElement Elem
    {
        get
        {
            try { return this._elem; }
            catch { return null; }
        }
    }
    #endregion

    #region  私有属性方法
    private string path = "";
    private XmlElement _elem=null;
    private XmlDocument doc = null;
    private void InitElement()
    {
        this.doc = new XmlDocument();
        //doc.Save();
        doc.Load(HttpContext.Current.Server.MapPath(this.path));
        this._elem = doc.DocumentElement;
    }
    #endregion



    #region  公有方法
    public virtual bool Update()
    {
        try
        {
            this.doc.Save(HttpContext.Current.Server.MapPath(this.path));
            return true;
        }
        catch
        {
            return false;
        }
    }
    #endregion


}